import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
	{
	  path: '/login',
	  name: 'login',
	  component: () => import('@/views/login')
  },{
		path: '/',
		name: 'layout',
		component: () => import('@/views/layout'),
		children: [
			{
				path: '/sys/user/list',
				name: 'sysUser',
				component: () => import('@/views/sys/user')
			},{
				path: '/sys/user/edit',
				name: 'sysUserEdit',
				component: () => import('@/views/sys/user/edit')
			},{
				path: '/sys/role/list',
				name: 'sysRole',
				component: () => import('@/views/sys/role')
			},{
				path: '/sys/role/edit',
				name: 'sysRoleEdit',
				component: () => import('@/views/sys/role/edit')
			},{
				path: '/sys/menu/list',
				name: 'sysMenu',
				component: () => import('@/views/sys/menu')
			},{
				path: '/sys/menu/edit',
				name: 'sysMenuEdit',
				component: () => import('@/views/sys/menu/edit')
			},{
				path: '/mall/goods/list',
				name: 'goodsList',
				component: () => import('@/views/mall/goods/list')
			},{
				path: '/mall/member/list',
				name: 'memberList',
				component: () => import('@/views/mall/member/list')
			},{
				path: '/mall/order/list',
				name: 'orderList',
				component: () => import('@/views/mall/order/list')
			},{
				path: '/mall/order/detail',
				name: 'orderDetail',
				component: () => import('@/views/mall/order/detail')
			},{
				path: '/mall/order/delivery',
				name: 'orderDelivery',
				component: () => import('@/views/mall/order/delivery')
			},{
				path: '/mall/orderReturn/list',
				name: 'orderReturnList',
				component: () => import('@/views/mall/orderReturn/list')
			},{
				path: '/mall/orderReturn/verify',
				name: 'orderReturnVerify',
				component: () => import('@/views/mall/orderReturn/verify')
			},{
				path: '/mall/orderReturn/detail',
				name: 'orderReturnDetail',
				component: () => import('@/views/mall/orderReturn/detail')
			}
		]
	}
]

const router = new VueRouter({
  routes
})

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

export default router
